﻿using Echo.Context.UltiProNet.Contexts;
using Echo.Core.Common;
using Echo.Core.TestAbstraction.WebUITest.MbUnit;
using Echo.Models.UltimateSoftware;
using Echo.Models.UltiProNet;
using MbUnit.Framework;
using System;

////*************************************************************************************************************************************
////Created by: Bryan Wexler
////Date Created: July 23, 2012 
////Existing SWAT Test: SuitePhoenix.SuiteGuiTests.SuiteW2PrintApproval.W2PrintApprovalSummaryGui
////Existing SWAT Test: SuitePhoenix.SuiteGuiTests.SuiteW2PrintApproval.W2PrintApprovalDetailGui
////ULTI-79413: YE: W-2 Print Approval Summary Updates
////ULTI-79421: YE: W-2 Print Approval Detail Updates
////ULTI-79429: YE: W-2 Print Approval Detail Page Message
////ULTI-75018: YE: Update W2 Approval page to indicate approval for printing only meeting new UX standards.
////ULTI-79462: YE: W-2 Print File Processing
////Number of Test Cases: 14
////*************************************************************************************************************************************

namespace Echo.Automation.Payroll.W2_Print_Approval
{
    [TestFixture]
    [Header("Config")]
    [Config(".NET")]
    [ForceRun]
    [Author("Bryan Wexler", "bryan_wexler@ultimatesoftware.com")]
    [Category("W2 Print Approval")]
    [Category("GUI")]
    public class W2PrintApprovalSummaryGui : AutomatedTest
    {
        UltiPro UltiPro;
        private UltiProDatabaseContext Database_SB340;
        private UltiProDatabaseContext Database_SB122;

        #region Queries

        private const string QueryUpdateYrsStatus = @"
            
            UPDATE YRStatus SET yrsStatus = 'READY', yrsDistributed = 'N' WHERE yrsStatus = 'FINAL' AND yrsTaxYear = '2008' 

            ";

        private const string QueryInsertPaW2ApprovalDates10_20 = @"
            
             INSERT INTO paW2approvaldates (paaFinalReconApprovalDate, paaFinalApprovalDate, paaYear) VALUES (dateadd(day, 10, getdate()), dateadd(day, 20, getdate()), 2008)

            ";

        private const string QueryInsertPaW2ApprovalDates_Minus1 = @"
            
             INSERT INTO paW2approvaldates (paaFinalApprovalDate, paaYear) VALUES (DATEADD(minute, -1, DATEADD(DAY, -1,DATEDIFF(DAY, -1, GETDATE()))), 2008)

            ";

        private const string QueryDelete = @"

            DELETE FROM paW2Approvals
            DELETE FROM paW2ApprovalDates WHERE paaYear = 2008
            DELETE FROM paW2ApprovalDates WHERE paaYear = 2007
            INSERT INTO paW2approvaldates (paaFinalReconApprovalDate, paaFinalApprovalDate, paaYear) VALUES (dateadd(day, 10, getdate()), dateadd(day, 20, getdate()), 2007)
            INSERT INTO paW2approvaldates (paaFinalReconApprovalDate, paaFinalApprovalDate, paaYear) VALUES (dateadd(day, 10, getdate()), dateadd(day, 20, getdate()), 2008)
            INSERT INTO paW2Approvals (pawAddressLine1, pawAddressLine2, pawApproved, pawApprovedBy, pawAttentionTo, pawChangedBy, pawChangedName, pawCity, pawDateTimeApproved, pawDateTimeChanged, pawDateTimePrinted, pawDateTimeReconApproved, pawDateTimeReconciled, pawPrintApprovedName, pawReconApprovedBy, pawReconApprovedName, pawReconciledBy, pawSortOrder, pawState, pawTaxGroup, pawYear, pawZipCode, pawRecipientUserID) VALUES ('6 Phoenix Boulevard', 'Suite 6B', '1', 'blackm', 'Felix Post', 'blackm', ' Michael A Black ', 'Weston', getdate(), getdate(), getdate(), getdate(), getdate(), ' Michael A Black ', 'blackm', 'Michael A Black ', 'blackm', 'YesNameLast,YesNameFirst,YesNameMiddle', 'FL', 'WPT62', '2007', '33326', 'ALLALLOCATIONSLASTLINDA_ARTRIP@ULTIMATESOFTWARE.')

            ";

        private const string QueryDeleteAllPaW2ApprovalDates = @"

            DELETE FROM paW2ApprovalDates

            ";

        private const string QueryDeleteAllpaW2Approvals = @"

            DELETE FROM paW2Approvals

            ";

        private const string QueryDeletePaW2Approvals_SB122 = @"
        
            DELETE FROM paW2Approvals

            ";

        private const string InsertPaW2ApprovalDates_SB122 = @"

            DELETE FROM paW2ApprovalDates WHERE paaYear = 2007
            DELETE FROM paW2ApprovalDates WHERE paaYear = 2008
            INSERT INTO paW2approvaldates (paaFinalReconApprovalDate, paaFinalApprovalDate, paaYear) VALUES (dateadd(day, 10, getdate()), dateadd(day, 20, getdate()), 2007)
            INSERT INTO paW2approvaldates (paaFinalReconApprovalDate, paaFinalApprovalDate, paaYear) VALUES (dateadd(day, 10, getdate()), dateadd(day, 20, getdate()), 2008)
            insert into paW2Approvals (pawAddressLine1, pawAddressLine2, pawApproved, pawApprovedBy, pawAttentionTo, pawChangedBy, pawChangedName, pawCity, pawDateTimeApproved, pawDateTimeChanged, pawDateTimePrinted, pawDateTimeReconApproved, pawDateTimeReconciled, pawPrintApprovedName, pawReconApprovedBy, pawReconApprovedName, pawReconciledBy, pawSortOrder, pawState, pawTaxGroup, pawYear, pawZipCode, pawRecipientUserID) VALUES ('6 Phoenix Boulevard', 'Suite 6B', '1', 'dyerp', 'Felix Post', 'dyerp', ' Paula A Dyer ', 'Weston', getdate(), getdate(), getdate(), getdate(), getdate(), ' Paula A Dyer ', 'dyerp', ' Paula A Dyer ', 'dyerp', 'YesOrgLvl1,YesOrgLvl2,YesOrgLvl3,YesNameLast,YesNameFirst,YesNameMiddle', 'FL', 'TAX2', '2007', '33326', 'BAGNUOLOP')

            ";

        private const string InsertW2PrintProcessedDate_SB122 = @"

            update paW2Approvals set pawDateTimePrinted = '2012-01-30 12:00:00.000' where pawTaxGroup = 'TAX2'

            ";

        private const string InsertW2PrintProcessedDate = @"

            update paW2Approvals set pawDateTimePrinted = '2012-01-30 12:00:00.000' where pawTaxGroup = 'LA2'

            ";

        private const string InsertW2ProdKey_SB122 = @"

            delete from RBSproductkeys where prkProdCode = 'W2PRT'
            insert into RBSproductkeys (prkProdKey, prkProdCode) VALUES ('BqCBpBbvY/P5bgx71ZaF4g==', 'W2PRT')

            ";

        private const string DeleteW2ProdKey_SB122 = @"

            delete from RBSproductkeys where prkProdCode = 'W2PRT'

            ";

        #endregion

        [FixtureSetUp]
        public void SetUp()
        {
            UltiPro = Launch<UltiPro>();

            Database_SB340 = Init<UltiProDatabaseContext>();
            Database_SB122 = Init<UltiProDatabaseContext>();
            Database_SB340.Company = ConfigDatabase("ULTIPRO_SB340");
            Database_SB122.Company = ConfigDatabase("ULTIPRO_SB122");

            string midnight = DateTime.Now.ToString("yyyy-MM-dd 00:00:00.000");

            Database_SB340.Company.AddRollBack("YrStatus", "yrsStatus = 'FINAL' and yrsTaxYear = '2008'");
            Database_SB340.Company.AddRollBack("paW2ApprovalDates");
            Database_SB340.Company.AddRollBack("paW2Approvals");
            Database_SB340.Company.AddRollBack("FileInfo", String.Format("filCreateDate > '{0}'", midnight));

            Database_SB122.Company.AddRollBack("paW2Approvals");
            Database_SB122.Company.AddRollBack("paW2ApprovalDates");
            Database_SB122.Company.AddRollBack("rbsProductKeys", "prkProdCode = 'W2RPT'");
            Database_SB122.Company.AddRollBack("FileInfo", String.Format("filCreateDate > '{0}'", midnight));

            // Remove existing set up records
            Database_SB340.Company.Execute(QueryDelete);
            Database_SB122.Company.Execute(QueryDeletePaW2Approvals_SB122);

            // Insert Dates and Product Keys
            Database_SB122.Company.Execute(InsertPaW2ApprovalDates_SB122);
            Database_SB122.Company.Execute(InsertW2ProdKey_SB122);

            // Backup 'YRStatus' table
            Database_SB340.Company.AddRollBack("YRStatus");
            Database_SB122.Company.AddRollBack("YRStatus");

            // Perform IIS Reset
            //Utilities.ResetIIS(Environment.UltiPro.WebServer);
            UltiPro.Macros.Cache.Reset(Environment.UltiPro.WebServer);

            // Login and navigate to W2 Print Approval Page
            UltiPro.Pages.Login.LoginAs("blackm", "password", Config.LanguageCode);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
        }

        [FixtureTearDown]
        public void TearDown()
        {
            UltiPro.Browser.Quit();
            //Database_SB340.Company.Execute(QueryDelete);
            //Database_SB122.Company.Execute(QueryDeletePaW2Approvals_SB122);
            //Database_SB122.Company.Execute(QueryDeleteAllPaW2ApprovalDates);
            //Database_SB122.Company.Execute(DeleteW2ProdKey_SB122);

            // Restore 'YRStatus' table
            Database_SB340.Company.RollBackDatabase();
            Database_SB122.Company.RollBackDatabase();

            // Perform IIS Reset
            //Utilities.ResetIIS(Environment.UltiPro.WebServer);
        }

        [Test(Order = 1)]
        public void Verify_W2_Print_Approval_link_is_available_when_company_has_product_key_W2PRT()
        {
            ////*************************************************************************************************************
            ////      Test Case 1: Verify W-2 Print Approval link is available when company has product key 'W2PRT'.
            ////      Test Data: blackm/password
            ////      Anticipated Results:  The W-2 Print Approval link is available.
            ////*************************************************************************************************************

            // TC_YEAM_GUI_W2AS_001: Verify W-2 Print Approval link is available when company has product key 'W2PRT'.
            Database_SB340.Company.Verify("SELECT count(*) FROM productkeys WHERE prkprodcode = 'W2PRT'", "W2PrintApprovalSummaryGui_VerifyProductkeys_0", 150);
            Database_SB340.Company.Verify("SELECT count(*) FROM rbsproductkeys WHERE prkprodcode = 'W2PRT'", "W2PrintApprovalSummaryGui_VerifyRbsProductkeys_0", 150);
            UltiPro.Pages.W2PrintApprovalSummary.Is(header => header.PageHeaderLabel, "innerHtml", UltiPro.Localization.Strings.W_hyphen_2_Print_Approval_Summary.ToTitleCase());
        }

        [Test(Order = 2)]
        public void Verify_W2_Print_information()
        {
            ////*************************************************************************************************************
            ////      Test Case 2: Verify W-2 Print information.
            ////      Test Data: Tax Group = WYE11
            ////      Anticipated Results:  The W-2 Print information is displayed correctly.
            ////*************************************************************************************************************

            // Add W-2 Print Detail information.
            // TC_YEAM_GUI_W2AS_025: Verify W-2 Print Approval summary page returns one record when find by is filtered by Tax group.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "WYE11");

            // TC_YEAM_GUI_W2AS_024: Verify that on the W-2 Print Approval summary page that Tax group appears in the form of a link which, when clicked, redirects to to the W-2 Print Approval details page.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "WYE11").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.PageHeaderLabel, "innerhtml", UltiPro.Localization.Strings.W_hyphen_2_Print_Approval.ToTitleCase());
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Cancel);
            UltiPro.Alert.Accept();
            UltiPro.Pages.W2PrintApprovalSummary.Is(header => header.PageHeaderLabel, "innerHtml", UltiPro.Localization.Strings.W_hyphen_2_Print_Approval_Summary.ToTitleCase());

            // Verify W-2 Print Detail Page information.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "WYE11");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "WYE11").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.Set(email => email.PrimaryEmailAddressTextBox, "elizsmith@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.Set(copyd => copyd.CopyRecipientsDropDown, "BLACKM");
            UltiPro.Pages.W2PrintApprovalDetail.Set(addemail => addemail.AdditionalEmailAddress1TextBox, "barca@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.Set(addemail => addemail.AdditionalEmailAddress2TextBox, "messi@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
        }

        [Test(Order = 3)]
        public void Verify_W2_Print_Summary_toolbars_and_controls()
        {
            ////*************************************************************************************************************
            ////      Test Case 3: Verify W-2 Print Summary toolbars and controls.
            ////      Test Data: Tax Group = WYE11
            ////      Anticipated Results:  The W-2 Print Summary toolbars and controls display correctly.
            ////*************************************************************************************************************

            // Tests from existing SWAT test
            // TC_YEAM_GUI_W2AS_003: Verify W-2 Print Approval summary page toolbar contains Print button and mouseover verbiage is print – print this page.
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.Exists(button => button.Print);
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.Is(button => button.Print, "alt", "print - print this page");

            // TC_YEAM_GUI_W2AS_004: Verify W-2 Print Approval summary page toolbar contains Help button and mouseover verbiage is help – help for this page.
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.Exists(button => button.Help);
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.Is(button => button.Help, "alt", "help - help for this page");

            // TC_YEAM_GUI_W2AS_005: Verify W-2 Print Approval summary page does not contain a Save button on the toolbar.
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.NotExists(button => button.Save);

            // TC_YEAM_GUI_W2AS_006: Verify W-2 Print Approval summary page does not contain a Reset button on the toolbar.
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.NotExists(button => button.Reset);

            // TC_YEAM_GUI_W2AS_007: Verify W-2 Print Approval summary page does not contain a Cancel button on the toolbar.
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.NotExists(button => button.Cancel);

            // TC_YEAM_GUI_W2AS_008: Verify W-2 Print Approval summary page does not contain a Delete button on the toolbar.
            UltiPro.Pages.W2PrintApprovalSummary.ButtonBar.NotExists(button => button.Delete);

            // TC_YEAM_GUI_W2AS_009: Verify W-2 Print Approval summary page contains page title of W-2 Print Approval Summary.
            UltiPro.Pages.W2PrintApprovalSummary.Is(header => header.PageHeaderLabel, "innerHtml", UltiPro.Localization.Strings.W_hyphen_2_Print_Approval_Summary.ToTitleCase());

            // TC_YEAM_GUI_W2AS_010: Verify W-2 Print Approval summary page has a find by control with options 'Tax group' and 'Federal Id'.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.HasOptions(dropdown => dropdown.ColumnFilter, SelectOption.Text, "Tax Group", "Federal ID");

            // TC_YEAM_GUI_W2AS_011: Verify W-2 Print Approval summary page find by control option 'Tax group' has drop down value options 'is' and 'is not'.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.HasOptions(dropdown => dropdown.TypeFilter, SelectOption.Text, "is", "is not");

            // TC_YEAM_GUI_W2AS_012: Verify W-2 Print Approval summary page find by control option 'Tax group' has drop down box with list of Tax groups.
            // TC_YEAM_GUI_W2AS_013: Verify W-2 Print Approval summary page find by control option 'Federal Id' has drop down value options 'is', 'is not' and 'starts with'.
            // TC_YEAM_GUI_W2AS_014: Verify W-2 Print Approval summary page find by control option 'Federal Id' has textbox in the third find by column.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.HasOptions(dropdown => dropdown.ValueFilter, SelectOption.Text, "WrkPL Taxgroup3", "WorkPlace 5");

            // New Requirements per ULTI-79413
            // 127.01: Yvonne is able to select the W-2 Print Approved column heading in order to sort by the date/time values.
            // UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Like(column => column.W2PrintApprovedHeader, "class", "unSorted");

            // 127.02: Yvonne is able to select the W-2 Print Processed column heading in order to sort by the date/time values.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Like(column => column.W2PrintProcessedHeader, "class", "unSorted");
        }

        [Test(Order = 4)]
        public void Verify_W2_Print_Summary_Data_Fields()
        {
            ////*************************************************************************************************************
            ////      Test Case 4: Verify W-2 Print Summary Data Fields.
            ////      Test Data: Tax Group = WYE11
            ////      Anticipated Results:  The W-2 Print Summary Data Fields display correctly.
            ////*************************************************************************************************************

            // Tests from existing SWAT test
            // TC_YEAM_GUI_W2AS_015: Verify W-2 Print Approval summary page contains a Tax group label on the grid's first column and column is sortable.
            // To Do: Sortability
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.TaxGroupHeader, "innerhtml", "Tax Group ");

            // TC_YEAM_GUI_W2AS_016: Verify W-2 Print Approval summary page contains a Tax group description label on the grid's second column.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.TaxGroupDescriptionHeader, "innerhtml", "Tax Group Description");

            // TC_YEAM_GUI_W2AS_017: Verify W-2 Print Approval summary page contains a Federal Id label on the grid's third column.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.FederalIdHeader, "innerhtml", "Federal ID");

            // TC_YEAM_GUI_W2AS_018: Verify W-2 Print Approval summary page contains a Shipping address label on the grid's fourth column.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.ShipppingAddressHeader, "innerhtml", "Shipping Address");

            // TC_YEAM_GUI_W2AS_019: Verify W-2 Print Approval summary page contains an W-2 print processed label on the grid's seventh column and column is sortable.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.W2PrintProcessed, "innerhtml", "W-2 Print Processed");

            // TC_YEAM_GUI_W2AS_028: Verify W-2 Print Approval summary page contains an W-2 reconciled label on the grid's sixth column and column is sortable.
            // Removed per ULTI-79413: UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.W2PrintApproved, "innerhtml", "W-2 Reconciled ");

            // TC_YEAM_GUI_W2AS_030: Verify W-2 Print Approval summary page contains an W-2 ready to be reconciled label on the grid's fifth column and column is sortable.
            // Removed per ULTI-79413: UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(label => label.W2ReadyHeader, "innerhtml", "W-2 Ready To Be Reconciled ");

            // New Requirements per ULTI-79412
            // 121.01: Since Yvonne the Year-End Specialist will no longer be approving tax groups for reconciliation by Payment Services the existing column W-2 Ready to be Reconciled must not display.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.NotExists(label => label.Column("W-2 Ready to be Reconciled"));
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.NotExists(label => label.Column("W-2 ready to be reconciled"));

            // 121.02: Since Penny from Payments Services will no longer be marking tax group year-end balances as reconciled the W-2 Reconciled column in the Summary is obsolete and must not display.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.NotExists(label => label.Column("W-2 Reconciled"));
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.NotExists(label => label.Column("W-2 reconciled"));

            // 121.03: W-2 Print Approved column appears to the right of Shipping Address.
            // UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Exists(label => label.Column("W-2 Print Approved"));
        }

        [Test(Order = 5)]
        public void Verify_W2_Print_Summary_Date_Time_Columns()
        {
            ////*************************************************************************************************************
            ////      Test Case 5: Verify W-2 Print Summary Date Time Columns.
            ////      Test Data: Tax Group = LA2
            ////      Anticipated Results:  The W-2 Print Summary Date Time Columns are correct.
            ////*************************************************************************************************************

            // 121.04: When Yvonne approves a tax group for printing (indicating the year-end balances were reconciled by her) the date and time she approves the tax group displays for the tax group in the W-2 Print Approved column.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "LA2");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "LA2").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.Set(email => email.PrimaryEmailAddressTextBox, "elizsmith@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.Set(copyd => copyd.CopyRecipientsDropDown, "BLACKM");
            UltiPro.Pages.W2PrintApprovalDetail.Click(button => button.PrintApprovalStatusCheckBox);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);

            // 135.00: All W-2 print service clients (both tax filing and non-tax filing) are prompted with an Important Message before approving a tax group for printing.
            // 135.01: When Yvonne selects the W-2 Processing Approval checkbox and then selects Save the Important Message lightbox appears for all W-2 print service clients.
            // 135.02: Verify the Important Message lightbox content.
            // 135.03: The year identified in the Important Message is the year being processed.
            // 135.04: The approval date identified in the Important Message is the Final Approval Date for the year being processed.
            var approvalYear = Database_SB340.Company.GetValue(string.Format("select paaYear from paW2ApprovalDates order by paaYear desc"));
            var finalApprovalDate = Database_SB340.Company.GetValue(string.Format("select CONVERT(VARCHAR(10), paaFinalApprovalDate, 101) from paW2ApprovalDates order by paaYear desc"));
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Is(header => header.Message, "innerhtml", "Important Message");
            // Below check updated and covered under W2DeliveryMethodTests.cs.
            //UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "If all payrolls and adjustments for this tax group are finalized and no further changes are required, then proceed. Ultimate Software will print and deliver your Forms W-2 to your shipping address.");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "You will not be able to process any additional payroll transactions for the " + approvalYear + " calendar year once you select OK.");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "Select Cancel if additional payroll transactions are required for this tax group.");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "Note: UltiPro will automatically approve this tax group for Form W-2 printing if approval is not completed by " + finalApprovalDate + ".");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(label => label.ImportantMessageCheckBoxLabel, "innerhtml", "If you have read the above information, select the checkbox to proceed and then click OK.");

            // Select ok on the confirmation box
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(checkbox => checkbox.CheckboxConfirm);
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(button => button.YesButton);

            // 135.05: Only when selecting OK from Important Message window updates the tax group's approved status, the date/time approved, the username that approved the tax group and the name of the user that approved the tax group and only for the current tax year.
            // 135.07: Tax group approval for printing must only update the tax group for the current tax year and NOT impact previous years.
            // 135.08: When a tax group has historical data when the multi-step approval process was in place then must be able to successfully approve the same tax group for printing using the one-step process.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "LA2");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "LA2").Click(link => link.TaxGroupLink);
            var pawDateTimeApproved = Database_SB340.Company.GetValue(string.Format("select pawDateTimeApproved from paW2Approvals where  pawTaxGroup = 'LA2' and paW2Approvals.pawApproved = 1 and pawYear = '2008'"));
            var pawDateTimeApprovedConverted = System.DateTime.Parse(pawDateTimeApproved).ToString("M'/'d'/'yyyy h':'mm tt");
            var pawApprovedBy = Database_SB340.Company.GetValue(string.Format("select pawApprovedBy from paW2Approvals where  pawTaxGroup = 'LA2' and paW2Approvals.pawApproved = 1 and pawYear = '2008'"));
            var pawPrintApprovedName = Database_SB340.Company.GetValue(string.Format("select RTRIM(LTRIM(pawPrintApprovedName)) from paW2Approvals where  pawTaxGroup = 'LA2' and paW2Approvals.pawApproved = 1 and pawYear = '2008'"));

            // 131.07: The name of the user who approved the W-2s for printing displays next to the date/time approved delimited with a slash (/).
            // 131.08: The user ID for the user that approved the W-2s for printing displays next to the user's name delimited with a slash (/).
            UltiPro.Pages.W2PrintApprovalDetail.Like(label => label.ApprovalDateSpan, "innerhtml", pawDateTimeApprovedConverted + "/" + pawPrintApprovedName + "/" + pawApprovedBy);
            UltiPro.Pages.W2PrintApprovalDetail.Like(label => label.OptionsChangedDateSpan, "innerhtml", pawDateTimeApprovedConverted + "/" + pawPrintApprovedName + "/" + pawApprovedBy);

            // Get W-2 Print Approved date/time from database and compare it to the date on the column
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "LA2");
            var printApprovedDateTime = Database_SB340.Company.GetValue(string.Format("select pawDateTimeApproved from paW2Approvals where pawTaxGroup = 'LA2' and pawYear = '2008'"));
            var convertedDate = System.DateTime.Parse(printApprovedDateTime).ToString("MM'/'dd'/'yyyy h':'mm tt");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "LA2").Is(datetime => datetime.W2PrintApprovedCell, "innerhtml", convertedDate);

            // 131.09: Once a tax group is approved for printing the W-2 Print Approval page is disabled for further changes.
            VerifyW2PrintApprovalDetailPageIsDisabled("LA2");

            // 121.05: When Yvonne has not approved a tax group for printing no value displays in the W-2 Print Approved column. An unselected checkbox does not appear in the column.
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "TAX4").Is(datetime => datetime.W2PrintApprovedCell, "innerhtml", "");

            // 121.06: When the system generates a W-2 print file for an approved tax group the date and time generated appears in the W-2 Print Processed column in place of a selected checkbox.
            // 121.07: The W-2 Print Processed column does not display a checkbox.
            Database_SB340.Company.Execute(InsertW2PrintProcessedDate);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "LA2").Is(datetime => datetime.W2PrintProcessedCell, "innerhtml", "01/30/2012 12:00 PM");
        }

        [Test(Order = 6)]
        public void Verify_W2_Print_Summary_Validations()
        {
            ////*************************************************************************************************************
            ////      Test Case 6: Verify W-2 Print Summary Validation.
            ////      Test Data: Tax Group = WYE11
            ////      Anticipated Results:  The W-2 Print Summary Validation is correct.
            ////*************************************************************************************************************

            // TC_YEAM_GUI_W2AS_026: Verify W-2 Print Approval summary page returns two records when find by is filtered by Federal Tax Id(FEIN).
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.FederalId, FilterType.Is, "999980322");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "WKPL3").RowExists();
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "WKPL4").RowExists();
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "WYE14").RowExists();
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "WYE15").RowExists();
        }

        [Test(Order = 7)]
        public void Verify_W2_Print_Detail_Page_Elements()
        {
            ////*************************************************************************************************************
            ////      Test Case 7: Verify W-2 Print Detail Page Elements.
            ////      Test Data: Tax Group = WPT62
            ////      Anticipated Results:  The W-2 Print Detail Page elements are correct.
            ////*************************************************************************************************************

            // Tests from existing SWAT test
            // Toolbar
            // TC_YEAM_GUI_W2AD_001: Verify W-2 Print Approval details tool bar contains Save button and toolbar hover text is save – save changes.
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "WPT62").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Is(button => button.Save, "alt", "save - save changes");

            // TC_YEAM_GUI_W2AD_002: Verify W-2 Print Approval details tool bar contains Reset button and toolbar hover text is reset – reset values.
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Reset);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Is(button => button.Reset, "alt", "reset - reset values");

            // TC_YEAM_GUI_W2AD_003: Verify W-2 Print Approval details tool bar contains Cancel button and toolbar hover text is cancel – cancel changes.
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Cancel);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Is(button => button.Cancel, "alt", "cancel - cancel changes");

            // TC_YEAM_GUI_W2AD_004: Verify W-2 Print Approval details tool bar contains Print button and toolbar hover text is print – print this page.
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Print);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Is(button => button.Print, "alt", "print - print this page");

            // TC_YEAM_GUI_W2AD_005: Verify W-2 Print Approval details tool bar contains Help button and toolbar hover text is help – help for this page.
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Help);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Is(button => button.Help, "alt", "help - help for this page");

            // TC_YEAM_GUI_W2AD_006: Verify W-2 Print Approval details tool bar does NOT contain Delete button.
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.NotExists(button => button.Delete);

            // TC_YEAM_GUI_W2AD_007: Verify W-2 Print Approval details tool bar does NOT contain Add button.
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.NotExists(button => button.Add);

            // Page title and subtitles
            // TC_YEAM_GUI_W2AD_008: Verify W-2 Print Approval details page has page title of W-2 Print Approval.
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.PageHeaderLabel, "innerhtml", UltiPro.Localization.Strings.W_hyphen_2_Print_Approval.ToTitleCase());

            // TC_YEAM_GUI_W2AD_009: Verify W-2 Print Approval details page contains a subtitle with background color of Tax Group.
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.TaxGroupHeaderLabel, "innerhtml", "Tax Group");

            // TC_YEAM_GUI_W2AD_010: Verify W-2 Print Approval details page contains a subtitle with background color of Shipping Address for W-2s.
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.ShippingAddressHeaderLabel, "innerhtml", "Shipping Address for W-2s");

            // TC_YEAM_GUI_W2AD_012: Verify W-2 Print Approval details page contains section heading with background color of W-2 Processing Approval.
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.ProcessingApprovalHeaderLabel, "innerhtml", "W-2 Processing Approval");

            // TC_YEAM_GUI_W2AD_013: Verify W-2 Print Approval details page contains section heading with background color of Date Approval.
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.DateApprovedHeaderLabel, "innerhtml", "Date Approved");

            // TC_YEAM_GUI_W2AD_011: Verify W-2 Print Approval details page contains section heading with background color of W-2 Sort Option.
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.SortOptionsHeaderLabel, "innerhtml", "W-2 Sort Options");

            // Tax group details
            // TC_YEAM_GUI_W2AD_014: Verify W-2 Print Approval details page contains Tax Year label and displays text with tax year value.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.TaxYearLabel, "innerhtml", "Tax Year");

            // TC_YEAM_GUI_W2AD_015: Verify W-2 Print Approval details page contains Tax Group label and displays text with tax group value.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.TaxGroupLabel, "innerhtml", "Tax Group");

            // TC_YEAM_GUI_W2AD_016: Verify W-2 Print Approval details page contains Tax Group Description label and displays text with Tax Group Description value.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.TaxGroupDescriptionLabel, "innerhtml", "Tax Group Description");

            // TC_YEAM_GUI_W2AD_017: Verify W-2 Print Approval details page contains Federal ID label and displays text with FEIN value.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.FederalIdLabel, "innerhtml", "Federal ID");

            // Shipping adddress for w-2s
            // TC_YEAM_GUI_W2AD_018: Verify W-2 Print Approval details page contains Attention To label and text input box.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.AttentionToLabel, "innerhtml", "Attention To");

            // TC_YEAM_GUI_W2AD_019: Verify W-2 Print Approval details page contains Address Line 1 label and text input box.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.AddressLine1Label, "innerhtml", "Address Line 1");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.AddressLine1TextBox);

            // TC_YEAM_GUI_W2AD_020: Verify W-2 Print Approval details page contains Address Line 2 label and text input box.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.AddressLine2Label, "innerhtml", "Address Line 2");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.AddressLine2TextBox);

            // TC_YEAM_GUI_W2AD_021: Verify W-2 Print Approval details page contains City label and text input box.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.CityLabel, "innerhtml", "City");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.CityTextBox);

            // TC_YEAM_GUI_W2AD_022: Verify W-2 Print Approval details page contains State label and select drop down.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.StateLabel, "innerhtml", "State");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(dropdown => dropdown.StateDropDown);

            // TC_YEAM_GUI_W2AD_023: Verify W-2 Print Approval details page contains Zip Code label and text input box.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.ZipLabel, "innerhtml", "Zip");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.ZipTextBox);

            // W-2 Notifications
            // TC:145331: Verify 'W-2 Notifications' text is present, left-justified, and with the same formatting as the other headers
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.NotificationsHeaderLabel, "innerhtml", "W-2 Notifications");

            // TC:145389: Verify 'Primary Email Address' text is present and box right next to its a required/enabled field.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.PrimaryEmailAddressLabel, "innerhtml", "Primary Email Address");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.PrimaryEmailAddressTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Is(inputbox => inputbox.PrimaryEmailAddressTextBox, "required", "true");

            // TC:145497: Verify 'Additional Email Address 1' text is present and box its disabled and not a required field.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.AdditionalEmailAddress1Label, "innerhtml", "Additional Email Address 1");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.AdditionalEmailAddress1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(inputbox => inputbox.AdditionalEmailAddress1TextBox);

            // TC:145498: Verify 'Additional Email Address 2' text is present and box its disabled and not a required field.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.AdditionalEmailAddress2Label, "innerhtml", "Additional Email Address 2");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(inputbox => inputbox.AdditionalEmailAddress2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(inputbox => inputbox.AdditionalEmailAddress2TextBox);

            // TC:145661: Verify 'Employer Copy D Recipient' text is present and drop-down box right next to its a required/enabled field.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.CopyRecipientsLabel, "innerhtml", "Employer Copy D Recipient");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(dropdown => dropdown.CopyRecipientsDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.Is(dropdown => dropdown.CopyRecipientsDropDown, "required", "true");

            // W-2 sort option & print approval
            // Removed per ULTI-79421: TC_YEAM_GUI_W2AD_025: Verify W-2 Print Approval details page contains W-2 print approval label and checkbox.

            // TC_YEAM_GUI_W2AD_024: Verify W-2 Print Approval details page contains W-2 sort option label and select drop down box.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.SortOptionsLabel, "innerhtml", "W-2 Sort Option");
            UltiPro.Pages.W2PrintApprovalDetail.Exists(dropdown => dropdown.SortOptionsDropDown);

            // TC_YEAM_GUI_W2AD_037: Verify W-2 Print Approval details page contains W-2 sort option values of last+first, pay group+last+first, location+last+first, org1-org2+org3+last+first
            UltiPro.Pages.W2PrintApprovalDetail.HasOption(dropdown => dropdown.SortOptionsDropDown, "YesNameLast,YesNameFirst,YesNameMiddle");
            UltiPro.Pages.W2PrintApprovalDetail.HasOption(dropdown => dropdown.SortOptionsDropDown, "YesPayGroup,YesNameLast,YesNameFirst,YesNameMiddle");
            UltiPro.Pages.W2PrintApprovalDetail.HasOption(dropdown => dropdown.SortOptionsDropDown, "YesLocation,YesNameLast,YesNameFirst,YesNameMiddle");
            UltiPro.Pages.W2PrintApprovalDetail.HasOption(dropdown => dropdown.SortOptionsDropDown, "YesOrgLvl1,YesOrgLvl2,YesOrgLvl3,YesNameLast,YesNameFirst,YesNameMiddle");

            // Removed per ULTI-79421: TC_YEAM_GUI_W2AD_060: Verify W-2 Print Approval details page contains 'Reconciliation of year-end balances and Form W-2 printing is approved to be completed' label and checkbox.

            // Date Approved
            // Ulti-41236: Verify W-2 Print Approval details page contains a 'W-2 Options Last Updated' label.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.OptionsChangedDateLabel, "innerhtml", "W-2 Options Last Updated");

            // Ulti-63796: Verify W-2 Print Approval details page contains a 'Print File Processed' label.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.PrintDateLabel, "innerhtml", "W-2 Print File Processed");

            // Error messages, required fields
            // TC_YEAM_GUI_W2AD_031: Verify W-2 Print Approval detail page produces an error when there is no value for Attention to.
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.AttentionToTextBox, "");

            // TC_YEAM_GUI_W2AD_032: Verify W-2 Print Approval detail page produces an error when there is no value for Address line 1.
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.AddressLine1TextBox, "");

            // TC_YEAM_GUI_W2AD_034: Verify W-2 Print Approval detail page produces an error when there is no value for City.
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.CityTextBox, "");

            // TC_YEAM_GUI_W2AD_035: Verify W-2 Print Approval detail page produces an error when there is no value for State. 
            UltiPro.Pages.W2PrintApprovalDetail.Set(dropdown => dropdown.StateDropDown, "");

            // TC_YEAM_GUI_W2AD_036: Verify W-2 Print Approval detail page produces an error when there is no value for Zip.
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.ZipTextBox, "");

            // TC_YEAM_GUI_W2AD_033: Verify W-2 Print Approval detail page does not produce an error when there is no value for Address line 2.
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.AddressLine2TextBox, "");

            // TC:145389: Verify W-2 Print Approval detail page produces an error when there is no value for Primary Email Address.
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.PrimaryEmailAddressTextBox, "");

            // TC:145662: Verify W-2 Print Approval detail page produces an error when there is no value for Employer Copy D Recipient.
            UltiPro.Pages.W2PrintApprovalDetail.Set(dropdown => dropdown.CopyRecipientsDropDown, "");

            // Click Save and verify errors
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 7 highlighted field(s) before continuing");

            // Reset data back - Attention To
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.AttentionToTextBox, "Felix Post");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 6 highlighted field(s) before continuing");

            // Reset data back - Address Line 1
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.AddressLine1TextBox, "6 Phoenix Boulevard");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 5 highlighted field(s) before continuing");

            // Reset data back - City
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.CityTextBox, "Weston");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 4 highlighted field(s) before continuing");

            // Reset data back - State
            UltiPro.Pages.W2PrintApprovalDetail.Set(dropdown => dropdown.StateDropDown, "FL");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 3 highlighted field(s) before continuing");

            // Reset data back - Zip Code
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.ZipTextBox, "333");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("US zip codes must contain 5 or 9 numeric characters");
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 2 highlighted field(s) before continuing");
            UltiPro.Pages.W2PrintApprovalDetail.Set(input => input.ZipTextBox, "33326");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 2 highlighted field(s) before continuing");

            // Reset data back - Primary Email Address
            UltiPro.Pages.W2PrintApprovalDetail.Set(email => email.PrimaryEmailAddressTextBox, "elizsmith@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ErrorMessages.Has("Please correct the 1 highlighted field(s) before continuing");

            // Reset data back - Employer Copy D Recipient
            UltiPro.Pages.W2PrintApprovalDetail.Set(copyd => copyd.CopyRecipientsDropDown, "BLACKM");

            // TC_YEAM_GUI_W2AD_061: Verify W-2 Print Approval details page does NOT contain 'Reconciliation of year-end balances and Form W-2 printing is approved to be completed' label and checkbox.
            // 131.03: In the Date Approved section the Year-End Balance Reconciled and associated date/time and user information for tax filing no longer display.
            UltiPro.Pages.W2PrintApprovalDetail.NotExists(label => label.ReconciliationApprovalStatusLabel);
            UltiPro.Pages.W2PrintApprovalDetail.NotExists(checkbox => checkbox.ReconciliationApprovalStatusCheckBox);

            // Ulti-41236: Verify W-2 Print Approval details page does not contain a 'Balances and W-2s approved' label.
            UltiPro.Pages.W2PrintApprovalDetail.NotExists(label => label.ReconApprovedDateLabel);

            // Ulti-41236: Verify W-2 Print Approval details page does not contain a 'Year-End Balances Reconciled' label.
            UltiPro.Pages.W2PrintApprovalDetail.NotExists(label => label.ReconciliationDateLabel);

            // 131.02: The W-2 Processing Approval checkbox label reads "W-2s are approved to be printed." regardless of tax filing status.
            UltiPro.Pages.W2PrintApprovalDetail.Is(
                label => label.LabelForPrintApprovalStatusCheckBox, "innerhtml", UltiPro.Localization.Strings.W_hyphen_2s_are_approved_to_be_printed.ToSentenceCase());

            // 131.05: In the Date Approved section the label W-2 Print File Approved displays below W-2 Options Last Updated.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.ApprovalDateLabel, "innerhtml", UltiPro.Localization.Strings.W_hyphen_2_Print_File_Approved.ToTitleCase());

            // 131.06: The date and time the W-2s are approved for printing display next to the W-2 Print File Approved label.
            UltiPro.Pages.W2PrintApprovalDetail.Exists(date => date.ApprovalDateSpan);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);
        }

        [Test(Order = 8)]
        public void Verify_that_the_tax_group_can_be_approved_for_printing_until_the_end_of_the_day_on_the_final_approval_date()
        {
            ////*************************************************************************************************************
            ////      Test Case 8: Verify that the tax group can be approved for printing until the end of the day on the final approval date.
            ////      Test Data: Tax Group = WPT61
            ////      Anticipated Results:  The Tax Group is available to be approved until the end of the day on the final approval date.
            ////*************************************************************************************************************

            // 131.01: As Yvonne the Year-End Specialist I want to be able to approve a tax group for printing until the end of the day on the final approval date.
            // Verify 6N+1 Robust Boundary Testing: (MinimalMax) Page is disabled.
            var todaysDateMinimalMax = Database_SB340.Company.GetValue(string.Format("SELECT DATEADD(day, -365, (select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMinimalMax + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsDisabled("WPT61");

            // Verify 6N+1 Robust Boundary Testing: (Minimal-) Page is disabled.
            var todaysDateMinimalMinus = Database_SB340.Company.GetValue(string.Format("SELECT DATEADD(day, -2, (select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMinimalMinus + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsDisabled("WPT61");

            // Verify 6N+1 Robust Boundary Testing: (Minimal) Page is disabled.
            var todaysDateMinimal = Database_SB340.Company.GetValue(string.Format("SELECT DATEADD(day, -1, (select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMinimal + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsDisabled("WPT61");

            // Verify 6N+1 Robust Boundary Testing: (Middle) Page is disabled.
            var todaysDateMiddle = Database_SB340.Company.GetValue(string.Format("SELECT ((select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMiddle + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsEnabled("WPT61");

            // Verify 6N+1 Robust Boundary Testing: (Maximum) Page is enabled.
            var todaysDateMaximum = Database_SB340.Company.GetValue(string.Format("SELECT DATEADD(day, 1, (select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMaximum + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsEnabled("WPT61");

            // Verify 6N+1 Robust Boundary Testing: (Maximum+) Page is enabled.
            var todaysDateMaximumPlus = Database_SB340.Company.GetValue(string.Format("SELECT DATEADD(day, 2, (select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMaximumPlus + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsEnabled("WPT61");

            // Verify 6N+1 Robust Boundary Testing: (MaximumMax) Page is enabled.
            var todaysDateMaximumMax = Database_SB340.Company.GetValue(string.Format("SELECT DATEADD(day, 365, (select convert(varchar(10),GETDate(), 101)))"));
            Database_SB340.Company.Execute("update paW2ApprovalDates set paaFinalApprovalDate = '" + todaysDateMaximumMax + "' where paaYear = '2008'");
            VerifyW2PrintApprovalDetailPageIsEnabled("WPT61");
        }

        [Test(Order = 9)]
        public void Verify_ALL_W2_print_service_clients_informational_and_error_messaging_are_the_same_for_both_tax_filing_and_nontax_filing_clients_on_the_W2_Print_Approval_detail_page()
        {
            ////*************************************************************************************************************
            ////      Test Case 9: 137.00: Verify ALL W-2 print service clients informational and error messaging are the same for both tax filing and non-tax filing clients on the W-2 Print Approval detail page.
            ////      Test Data: Tax Group = WP5 and WKPL1
            ////      Anticipated Results:  The messages are the same for both tax filing and non-tax filing clients on the W-2 Print Approval detail page.
            ////*************************************************************************************************************

            // 137.01, 137.02: When a tax group is accessed from the Summary page and the tax group has active and not closed payrolls for the year being processed an informational message appears below the page title
            Database_SB340.Company.VerifyRecordCount("SELECT TOP 1 pgppaygroup FROM company (NOLOCK) JOIN pygrcomp (NOLOCK) ON cmpcoid = pgccoid JOIN pgpayper (NOLOCK) ON pgpPayGroup = pgcPayGroup WHERE cmptaxcalcgroupid = 'WP5' AND pgpperiodcontrol LIKE '2008' + '%' AND pgpactive = 'Y' AND pgpisperiodclosed = 'N'", 1, 150);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "WP5");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "WP5").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.InformationMessages.HasPartial("There are active payrolls for one or more pay groups associated to the selected tax group that are not completed for the year.");
            UltiPro.Pages.W2PrintApprovalDetail.InformationMessages.HasPartial("Active payrolls for all pay groups must be completed for the year before W-2 Processing Approval check box is available.");

            // 137.04: When active and open payrolls exist for the tax year for the tax group the W-2 Processing Approval checkbox is disabled.  Disabled checkbox is new for non-tax filing clients.
            VerifyW2PrintApprovalDetailPageIsEnabledExceptPrintApprovalStatusCheckBox("WP5");

            // Logout and log back in
            UltiPro.Macros.Logout.Of_UltiPro();
            UltiPro.Pages.Login.LoginAs("dyerp", "password", Config.LanguageCode);
            Database_SB122.Company.Verify("SELECT count(*) FROM rbsproductkeys WHERE prkprodcode = 'W2PRT'", "W2PrintApprovalSummaryGui_VerifyRbsProductkeys_0", 15);
            Database_SB122.Company.VerifyRecordCount("SELECT TOP 1 pgppaygroup FROM company (NOLOCK) JOIN pygrcomp (NOLOCK) ON cmpcoid = pgccoid JOIN pgpayper (NOLOCK) ON pgpPayGroup = pgcPayGroup WHERE cmptaxcalcgroupid = 'WKPL1' AND pgpperiodcontrol LIKE '2008' + '%' AND pgpactive = 'Y' AND pgpisperiodclosed = 'N'", 1, 15);

            // 137.01, 137.02: When a tax group is accessed from the Summary page and the tax group has active and not closed payrolls for the year being processed an informational message appears below the page title
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "WKPL1");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "WKPL1").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.InformationMessages.HasPartial("There are active payrolls for one or more pay groups associated to the selected tax group that are not completed for the year.");
            UltiPro.Pages.W2PrintApprovalDetail.InformationMessages.HasPartial("Active payrolls for all pay groups must be completed for the year before W-2 Processing Approval check box is available.");

            // 137.04: When active and open payrolls exist for the tax year for the tax group the W-2 Processing Approval checkbox is disabled.  Disabled checkbox is new for non-tax filing clients.
            VerifyW2PrintApprovalDetailPageIsEnabledExceptPrintApprovalStatusCheckBox("WKPL1");
        }

        [Test(Order = 10)]
        public void Verify_that_if_the_client_is_NOT_an_UltiTax_tax_filing_client_they_see_when_a_tax_group_has_been_approved_for_printing_and_when_the_file_has_been_processed()
        {
            ////*************************************************************************************************************
            ////      Test Case 10: 125.00: Verify that if the client is NOT an UltiTax tax filing client they see when a tax group has been approved for printing and when the file has been processed.
            ////      Test Data: user: dyerp/password
            ////      Anticipated Results:  The non-tax filing client still sees when tax group has been approved for printing and when the file has been processed.
            ////*************************************************************************************************************

            // 125.01: When Yvonne approves a tax group for printing  the date and time she approves the tax group displays for the tax group in the W-2 Print Approved column instead of a selected checkbox.
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "TAX2");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "TAX2").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.Is(header => header.PageHeaderLabel, "innerhtml", UltiPro.Localization.Strings.W_hyphen_2_Print_Approval.ToTitleCase());
            UltiPro.Pages.W2PrintApprovalDetail.Set(email => email.PrimaryEmailAddressTextBox, "elizsmith@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.Set(copyd => copyd.CopyRecipientsDropDown, "BLACKS");
            UltiPro.Pages.W2PrintApprovalDetail.Click(button => button.PrintApprovalStatusCheckBox);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);

            // 131.02: The W-2 Processing Approval checkbox label reads "W-2s are approved to be printed." regardless of tax filing status.
            UltiPro.Pages.W2PrintApprovalDetail.Is(
                label => label.LabelForPrintApprovalStatusCheckBox, "innerhtml", UltiPro.Localization.Strings.W_hyphen_2s_are_approved_to_be_printed.ToSentenceCase());

            // 131.05: In the Date Approved section the label W-2 Print File Approved displays below W-2 Options Last Updated.
            UltiPro.Pages.W2PrintApprovalDetail.Is(label => label.ApprovalDateLabel, "innerhtml", "W-2 Print File Approved");

            // 131.06: The date and time the W-2s are approved for printing display next to the W-2 Print File Approved label.
            UltiPro.Pages.W2PrintApprovalDetail.Exists(date => date.ApprovalDateSpan);

            // Verify the W-2 Print File Approved Checkbox and Label does not exist.
            // UltiPro.Pages.W2PrintApprovalDetail.NotExists(label => label.PrintApprovalStatusLabel);
            // UltiPro.Pages.W2PrintApprovalDetail.NotExists(label => label.PrintApprovalStatusCheckBox);

            // 135.00: All W-2 print service clients (both tax filing and non-tax filing) are prompted with an Important Message before approving a tax group for printing.
            // 135.01: When Yvonne selects the W-2 Processing Approval checkbox and then selects Save the Important Message lightbox appears for all W-2 print service clients.
            // 135.02: Verify the Important Message lightbox content.
            // 135.03: The year identified in the Important Message is the year being processed.
            // 135.04: The approval date identified in the Important Message is the Final Approval Date for the year being processed.
            var approvalYear = Database_SB122.Company.GetValue(string.Format("select paaYear from paW2ApprovalDates order by paaYear desc"));
            var finalApprovalDate = Database_SB122.Company.GetValue(string.Format("select CONVERT(VARCHAR(10), paaFinalApprovalDate, 101) from paW2ApprovalDates order by paaYear desc"));
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Is(header => header.Message, "innerhtml", "Important Message");
            // Below check updated and covered under W2DeliveryMethodTests.cs.
            // UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "If all payrolls and adjustments for this tax group are finalized and no further changes are required, then proceed. Ultimate Software will print and deliver your Forms W-2 to your shipping address.");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "You will not be able to process any additional payroll transactions for the " + approvalYear + " calendar year once you select OK.");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "Select Cancel if additional payroll transactions are required for this tax group.");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(body => body.ImportantMessageText, "innerhtml", "Note: UltiPro will automatically approve this tax group for Form W-2 printing if approval is not completed by " + finalApprovalDate + ".");
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Like(label => label.ImportantMessageCheckBoxLabel, "innerhtml", "If you have read the above information, select the checkbox to proceed and then click OK.");

            // Select ok on the confirmation box
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(checkbox => checkbox.CheckboxConfirm);
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(button => button.YesButton);

            // 135.05: Only when selecting OK from Important Message window updates the tax group's approved status, the date/time approved, the username that approved the tax group and the name of the user that approved the tax group and only for the current tax year.
            // 135.06: For tax-filing W-2 print service clients approval is now final approval like non-tax filing client.
            // 135.07: Tax group approval for printing must only update the tax group for the current tax year and NOT impact previous years.
            // 135.08: When a tax group has historical data when the multi-step approval process was in place then must be able to successfully approve the same tax group for printing using the one-step process.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "TAX2");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "TAX2").Click(link => link.TaxGroupLink);
            var pawDateTimeApproved = Database_SB122.Company.GetValue(string.Format("select pawDateTimeApproved from paW2Approvals where  pawTaxGroup = 'TAX2' and paW2Approvals.pawApproved = 1 and pawYear = '2008'"));
            var pawDateTimeApprovedConverted = System.DateTime.Parse(pawDateTimeApproved).ToString("M'/'d'/'yyyy h':'mm tt");
            var pawApprovedBy = Database_SB122.Company.GetValue(string.Format("select pawApprovedBy from paW2Approvals where  pawTaxGroup = 'TAX2' and paW2Approvals.pawApproved = 1 and pawYear = '2008'"));
            var pawPrintApprovedName = Database_SB122.Company.GetValue(string.Format("select RTRIM(LTRIM(pawPrintApprovedName)) from paW2Approvals where  pawTaxGroup = 'TAX2' and paW2Approvals.pawApproved = 1 and pawYear = '2008'"));

            // 131.07: The name of the user who approved the W-2s for printing displays next to the date/time approved delimited with a slash (/).
            // 131.08: The user ID for the user that approved the W-2s for printing displays next to the user's name delimited with a slash (/).
            UltiPro.Pages.W2PrintApprovalDetail.Like(label => label.ApprovalDateSpan, "innerhtml", pawDateTimeApprovedConverted + "/" + pawPrintApprovedName + "/" + pawApprovedBy);
            UltiPro.Pages.W2PrintApprovalDetail.Like(label => label.OptionsChangedDateSpan, "innerhtml", pawDateTimeApprovedConverted + "/" + pawPrintApprovedName + "/" + pawApprovedBy);

            // 131.09: Once a tax group is approved for printing the W-2 Print Approval page is disabled for further changes.
            VerifyW2PrintApprovalDetailPageIsDisabled("TAX2");

            // Get W-2 Print Approved date/time from database and compare it to the date on the column
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            var printApprovedDateTime = Database_SB122.Company.GetValue(string.Format("select pawDateTimeApproved from paW2Approvals where pawTaxGroup = 'TAX2' and pawYear = '2008'"));
            var convertedDate = System.DateTime.Parse(printApprovedDateTime).ToString("MM'/'dd'/'yyyy h':'mm tt");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "TAX2").Is(datetime => datetime.ShippingAddressCell, "innerhtml", convertedDate);

            // 125.02: When Yvonne has not approved a tax group for printing no value displays in the W-2 Print Approved column. An unselected checkbox does not appear in the column.
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "WKPL1").Is(datetime => datetime.ShippingAddressCell, "innerhtml", "");

            // 125.03: When Yvonne views the Summary page the W-2 Print Processed column appears to the right of W-2 Print Approved column.
            // 125.04: When the system generates a W-2 print file for an approved tax group the date and time generated appears in the W-2 Print Processed column.
            Database_SB122.Company.Execute(InsertW2PrintProcessedDate_SB122);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(cell => cell.TaxGroupLink, "TAX2").Is(datetime => datetime.W2PrintApprovedCell, "innerhtml", "01/30/2012 12:00 PM");
        }

        [Test(Order = 11)]
        public void Verify_W2_Print_Summary_does_not_display_tax_groups_when_the_Final_Approval_dates_do_not_exist()
        {
            ////*************************************************************************************************************
            ////      Test Case 11: Verify W-2 Print Summary does not display tax groups when the Final Approval dates do not exist.
            ////      Test Data: Tax Group = WYE11
            ////      Anticipated Results:  The Tax Groups do not display.
            ////*************************************************************************************************************

            // TC_YEAM_GUI_W2AS_027: Verify W-2 Print Approval summary page does not display any tax group records when there are no records with Final Approval dates in paW2ApprovalDates.
            Database_SB122.Company.Execute(QueryDeleteAllPaW2ApprovalDates);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Is(control => control.GridMessage, "innerHTML", "No records found");
        }

        [Test(Order = 12)]
        public void Verify_W2_Print_Approval_link_is_not_available_when_company_does_not_have_product_key_W2PRT()
        {
            ////*************************************************************************************************************
            ////      Test Case 12: Verify W-2 Print Approval link is not available when company does not have product key 'W2PRT'.
            ////      Test Data: user: PasS/password
            ////      Anticipated Results:  The W-2 Print Approval link does not display.
            ////*************************************************************************************************************

            // TC_YEAM_GUI_W2AS_002: Verify W-2 Print Approval link is not available when company does not have product key 'W2PRT'.
            UltiPro.Macros.Logout.Of_UltiPro();
            UltiPro.Pages.Login.LoginAs("PasS", "password", Config.LanguageCode);
            UltiPro.Menu.Reporting.NotExists(link => link.W2PrintApproval);
            UltiPro.Browser.Quit();
        }

        [Test(Order = 13)]
        public void Verify_that_When_the_Deadline_for_Final_Approval_passes_midnight_of_the_date_specified_any_tax_groups_not_already_approved_for_printing_are_marked_as_approved_by_the_system_for_Tax_Filing_Clients()
        {
            ////*************************************************************************************************************
            ////      Test Case 13: Verify that when the Deadline for Final Approval passes (midnight of the date specified) any tax groups not already approved for printing are marked as approved by the system for Tax Filing Clients.
            ////      Test Data: user: Blackm/password
            ////      Anticipated Results:  The tax groups not already approved for printing are marked as approved by the system.
            ////*************************************************************************************************************

            // 210.01: When the Deadline for Final Approval passes (midnight of the date specified) any tax groups not already approved for printing are marked as approved by the system.
            // Delete all date and approval data
            Database_SB340.Company.Execute(QueryDeleteAllPaW2ApprovalDates);
            Database_SB340.Company.Execute(QueryDeleteAllpaW2Approvals);

            // 210.04: When the Deadline for Final Approval passes (midnight of the date specified) any tax groups already approved for printing are not updated by the system.
            // Approve a tax group to verify that only the remaining tax groups which have not been approved will automatically be approved by the System job.
            Database_SB340.Company.Execute(QueryInsertPaW2ApprovalDates10_20);

            // Login into the system and approve 1 tax group
            UltiPro = Launch<UltiPro>();
            UltiPro.Pages.Login.LoginAs("Blackm", "password", Config.LanguageCode);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "LA2");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "LA2").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.Set(email => email.PrimaryEmailAddressTextBox, "elizsmith@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.Set(copyd => copyd.CopyRecipientsDropDown, "BLACKM");
            UltiPro.Pages.W2PrintApprovalDetail.Click(button => button.PrintApprovalStatusCheckBox);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);

            // Select ok on the confirmation box
            System.Threading.Thread.Sleep(1000);
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(checkbox => checkbox.CheckboxConfirm);
            System.Threading.Thread.Sleep(2000);
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(button => button.YesButton);
            System.Threading.Thread.Sleep(2000);

            // Verify the record is saved.
            Database_SB340.Company.VerifyRecordCount("select * from paW2Approvals", 1, 150);
            Database_SB340.Company.Verify("select pawAddressLine1, pawAddressLine2, pawApproved, pawApprovedBy, pawAttentionTo, pawChangedBy, pawChangedName, pawCity, pawDateTimePrinted, pawDateTimeReconApproved, pawDateTimeReconciled, pawPrintApprovedName, pawReconApprovedBy, pawReconApprovedName, pawReconciledBy, pawSortOrder, pawState, pawTaxGroup, pawYear, pawZipCode, pawRecipientUserID from paW2Approvals", "W2PrintApprovalSummaryGui_VerifyApprovedTaxGroup_0", 150);

            // Insert the final approval date to be one day before today's date and be one minute before midnight
            Database_SB340.Company.Execute(QueryDeleteAllPaW2ApprovalDates);
            Database_SB340.Company.Execute(QueryInsertPaW2ApprovalDates_Minus1);

            // Set any Tax groups that are not in the Ready status to be Ready before running the job
            Database_SB340.Company.Execute(QueryUpdateYrsStatus);

            // Run the W-2 Approval Job
            Database_SB340.Company.Execute("EXEC msdb..sp_start_job 'W2ApproveAndSubmitJob'");

            // Verify the Tax Groups have been auto approved
            //Database_SB340.Company.VerifyRecordCount("select * from paW2Approvals", 22, 150);
            Database_SB340.Company.Verify("select pawAddressLine1, pawAddressLine2, pawApproved, pawApprovedBy, pawAttentionTo, pawChangedBy, pawChangedName, pawCity, pawDateTimePrinted, pawDateTimeReconApproved, pawDateTimeReconciled, pawPrintApprovedName, pawReconApprovedBy, pawReconApprovedName, pawReconciledBy, pawSortOrder, pawState, pawTaxGroup, pawYear, pawZipCode, pawRecipientUserID from paW2Approvals order by pawTaxGroup", "W2PrintApprovalSummaryGui_VerifyApprovedTaxGroup_1", 150);
            UltiPro.Macros.Logout.Of_UltiPro();
        }

        [Test(Order = 14)]
        public void Verify_that_When_the_Deadline_for_Final_Approval_passes_midnight_of_the_date_specified_any_tax_groups_not_already_approved_for_printing_are_marked_as_approved_by_the_system_for_NON_Tax_Filing_Clients()
        {
            ////*************************************************************************************************************
            ////      Test Case 14: Verify that when the Deadline for Final Approval passes (midnight of the date specified) any tax groups not already approved for printing are marked as approved by the system for NON Tax Filing Clients.
            ////      Test Data: user: DyerP/password
            ////      Anticipated Results:  The tax groups not already approved for printing are marked as approved by the system.
            ////*************************************************************************************************************

            // 210.02: When the Deadline for Final Approval passes (midnight of the date specified) any tax groups not already approved for printing are marked as approved by the system for NON Tax Filing Clients.
            // Delete all date and approval data
            Database_SB122.Company.Execute(QueryDeleteAllPaW2ApprovalDates);
            Database_SB122.Company.Execute(QueryDeleteAllpaW2Approvals);

            // 210.04: When the Deadline for Final Approval passes (midnight of the date specified) any tax groups already approved for printing are not updated by the system.
            // Approve a tax group to verify that only the remaining tax groups which have not been approved will automatically be approved by the System job.
            Database_SB122.Company.Execute(QueryInsertPaW2ApprovalDates10_20);

            // Login into the system and approve 1 tax group
            UltiPro.Pages.Login.LoginAs("DyerP", "password", Config.LanguageCode);
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Find(group => group.TaxGroupFilter, FilterType.Is, "TAX2");
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, "TAX2").Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.Set(email => email.PrimaryEmailAddressTextBox, "elizsmith@domain.com");
            UltiPro.Pages.W2PrintApprovalDetail.Set(copyd => copyd.CopyRecipientsDropDown, "BLACKS");
            UltiPro.Pages.W2PrintApprovalDetail.Click(button => button.PrintApprovalStatusCheckBox);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Click(button => button.Save);

            // Select ok on the confirmation box
            System.Threading.Thread.Sleep(1000);
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(checkbox => checkbox.CheckboxConfirm);
            System.Threading.Thread.Sleep(2000);
            UltiPro.Pages.W2PrintApprovalDetail.ConfirmBox.Click(button => button.YesButton);
            System.Threading.Thread.Sleep(2000);

            // Verify the record is saved.
            Database_SB122.Company.VerifyRecordCount("select * from paW2Approvals", 1, 150);
            Database_SB122.Company.Verify("select pawAddressLine1, pawAddressLine2, pawApproved, pawApprovedBy, pawAttentionTo, pawChangedBy, pawChangedName, pawCity, pawDateTimePrinted, pawDateTimeReconApproved, pawDateTimeReconciled, pawPrintApprovedName, pawReconApprovedBy, pawReconApprovedName, pawReconciledBy, pawSortOrder, pawState, pawTaxGroup, pawYear, pawZipCode, pawRecipientUserID from paW2Approvals", "W2PrintApprovalSummaryGui_VerifyApprovedTaxGroup_2", 150);

            // Insert the final approval date to be one day before today's date and be one minute before midnight
            Database_SB122.Company.Execute(QueryDeleteAllPaW2ApprovalDates);
            Database_SB122.Company.Execute(QueryInsertPaW2ApprovalDates_Minus1);

            // Set any Tax groups that are not in the Ready status to be Ready before running the job
            Database_SB122.Company.Execute(QueryUpdateYrsStatus);

            // Run the W-2 Approval Job
            Database_SB122.Company.Execute("EXEC msdb..sp_start_job 'W2ApproveAndSubmitJob'");

            // Verify the Tax Groups have been auto approved
            Database_SB122.Company.VerifyRecordCount("select * from paW2Approvals", 11, 150);
            Database_SB122.Company.Verify("select pawAddressLine1, pawAddressLine2, pawApproved, pawApprovedBy, pawAttentionTo, pawChangedBy, pawChangedName, pawCity, pawDateTimePrinted, pawDateTimeReconApproved, pawDateTimeReconciled, pawPrintApprovedName, pawReconApprovedBy, pawReconApprovedName, pawReconciledBy, pawSortOrder, pawState, pawTaxGroup, pawYear, pawZipCode, pawRecipientUserID from paW2Approvals order by pawTaxGroup", "W2PrintApprovalSummaryGui_VerifyApprovedTaxGroup_3", 150);
        }

        #region Helper Methods

        public void VerifyW2PrintApprovalDetailPageIsDisabled(string TaxGroup)
        {
            // Verifies that the W-2 Print Approval Detail Page is disabled
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, TaxGroup).Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.NotExists(button => button.Cancel);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.NotExists(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.NotExists(button => button.Reset);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AttentionToTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AddressLine1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AddressLine2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.CityTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.StateDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.ZipTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.PrimaryEmailAddressTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AdditionalEmailAddress1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AdditionalEmailAddress2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.CopyRecipientsDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(checkbox => checkbox.PrintApprovalStatusCheckBox);
        }

        public void VerifyW2PrintApprovalDetailPageIsEnabled(string TaxGroup)
        {
            // Verifies that the W-2 Print Approval Detail Page is enabled
            UltiPro.Menu.Reporting.Click(link => link.W2PrintApproval);
            UltiPro.Pages.W2PrintApprovalSummary.W2PrintApprovalSummaryGrid.Row(row => row.TaxGroupLink, TaxGroup).Click(link => link.TaxGroupLink);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Cancel);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Reset);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.AttentionToTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.AddressLine1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.AddressLine2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.CityTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.StateDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.ZipTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.PrimaryEmailAddressTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AdditionalEmailAddress1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AdditionalEmailAddress2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.CopyRecipientsDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(checkbox => checkbox.PrintApprovalStatusCheckBox);
        }

        public void VerifyW2PrintApprovalDetailPageIsEnabledExceptPrintApprovalStatusCheckBox(string TaxGroup)
        {
            // Verifies that the W-2 Print Approval Detail Page is enabled
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Cancel);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Save);
            UltiPro.Pages.W2PrintApprovalDetail.ButtonBar.Exists(button => button.Reset);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.AttentionToTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.AddressLine1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.AddressLine2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.CityTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.StateDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.ZipTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.PrimaryEmailAddressTextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AdditionalEmailAddress1TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(input => input.AdditionalEmailAddress2TextBox);
            UltiPro.Pages.W2PrintApprovalDetail.Enabled(input => input.CopyRecipientsDropDown);
            UltiPro.Pages.W2PrintApprovalDetail.NotEnabled(checkbox => checkbox.PrintApprovalStatusCheckBox);
        }

        #endregion
    }
}
